package com.maddox.mworld;

import android.Manifest;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.FileProvider;


import com.maddox.relax.camera.c1.Camera1PicActivity;
import com.maddox.relax.camera.c2.Camera2PicActivity;
import com.maddox.relax.util.PBitmapUtils;

import java.io.File;
import java.io.IOException;


public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button upload1,upload2;
//    private AutoScrollTextView textView, textView1, textView2, textView3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        upload1 = (Button) findViewById(R.id.upload1);
        upload2 = (Button) findViewById(R.id.upload2);
        upload1.setOnClickListener(this);
        upload2.setOnClickListener(this);
//        textView = findViewById(R.id.mTextView);

//
//        textView.setText("norpjwer");
//        textView.init();
//        textView.startScroll();

        initPermission();

    }

    private void initPermission() {
        String[] permission = {
                Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.ACCESS_COARSE_LOCATION,
                Manifest.permission.LOCATION_HARDWARE,
                Manifest.permission.NFC,
                Manifest.permission.BLUETOOTH_PRIVILEGED,
                Manifest.permission.BLUETOOTH_ADMIN,
                Manifest.permission.BLUETOOTH,
                Manifest.permission.READ_PHONE_STATE,
                Manifest.permission.INTERNET,
                Manifest.permission.WRITE_EXTERNAL_STORAGE,
                Manifest.permission.CAMERA,
                Manifest.permission.RECORD_AUDIO
        };
        ActivityCompat.requestPermissions(this, permission, 10);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.upload1:
//                startActivity(new Intent(this, NfcReadActivity.class));
//                startActivity(new Intent(this, BluetoothServerActivity.class));
//                startActivity(new Intent(this, BluetoothListActivity.class));
//                startActivity(new Intent(this, BleListActivity.class));
//                startActivity(new Intent(this, VideoRecoderActivity.class));
//                String filePath = PBitmapUtils.getPickerFileDirectory(this) + File.separator + "qweqwe.jpg";
//                File file = new File(filePath);
//                if (!file.exists()){
//                    try {
//                        file.createNewFile();
//                    } catch (IOException e) {
//                        e.printStackTrace();
//                    }
//                }
//                Uri uriForFile = FileProvider.getUriForFile(this, "com.maddox.mworld.fileprovider", new File(filePath));
                Intent intent = new Intent(this, Camera2PicActivity.class);
//                intent.putExtra("filePath",filePath);
                startActivity(intent);
                break;
            case R.id.upload2:
//                startActivity(new Intent(this, NfcWriteActivity.class));
                break;
        }
    }






}